// JavaScript Document

$(function(){
	$("#btnLogin").bind("click",function(){
		login();	
	})
});

function login(){
	var user=get("user");
	var pwd=get("pwd");
	var category=$('input[name=category]:checked');
	
	ajax({
		url:"index.php/DB/login",
		data:{
			user:user.value,
			pwd:pwd.value,
			category:category.attr("id")
		},
		callback:function(content){
			var json=text2json(content);
			
			if(json.state=="ok"){
				if(category.attr("id")=="teacher"){
					window.location.href="index.php/manage/manageTeacher";
				}else{
					window.location.href="index.php/manage/manageSdt";	
				}
			}else{
				alert(lang.user_login_error);
			}
		}
	});
}
